﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication1
{
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            var uid = TextBox1.Text.Trim();
            var pwd = TextBox2.Text.Trim();

            var sql = string.Format("select * from Users where Username ='{0}'and Password = '{1}'", uid, pwd);
            var dt = Dbhelper.GetDataTable(sql);
            if (dt.Rows.Count == 1)
            {
                var row = dt.Rows[0];
                var IsActived = (bool)row.ItemArray[3];
                var IsDeleted = (bool)row.ItemArray[4];
                if (IsDeleted)
                {
                    Label3.Text = "该账户已被删除";
                }

                else
                {
                    if (IsActived)
                    {
                        Response.Redirect("Default.aspx");
                    }
                    else
                    {
                        Label3.Text = "该账号已过期";
                    }
                }
            }
            else {
                Label3.Text = "账号或密码错误";
            }
        }
    }
}
